package Unidad4;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ProgramaHilo extends Thread {

	public void run() {

	/*	while (1 == 1) {

			try {

				Thread.sleep(5000);

			} catch (Exception e) {
				e.printStackTrace();

			}
			long mem0 = Runtime.getRuntime().totalMemory();
			long mem1 = Runtime.getRuntime().freeMemory();
			long mem2 = Runtime.getRuntime().availableProcessors();
			long mem3 = Runtime.getRuntime().maxMemory();
			
			System.out.println("Memoria Total   "+mem0);
			System.out.println("Memoria Libre  "+ mem1);
			System.out.println("Procesos Disponibles   "+ mem2);
			System.out.println("Memoria Maxima   "+ mem3+"\n");
		}
*/ while(1==1){
		try {
			Process proceso = Runtime.getRuntime().exec("ps -ef");//ls

			BufferedReader stdInput = new BufferedReader(new InputStreamReader(
								proceso.getInputStream()));

			BufferedReader stdError = new BufferedReader(new InputStreamReader(
								proceso.getErrorStream()));

						
				String s = null;
						
				System.out.println("Here is the standard output of the command:\n");
				while ((s = stdInput.readLine()) != null) {
					System.out.println(s);
				}
				System.out.println("Here is the standard error of the command (if any):\n");

			          while ((s = stdError.readLine()) != null) {
			                System.out.println(s);
			          }
			            
			          System.exit(0);

			} catch (IOException e) {
				e.printStackTrace();
			}
}
		
		
	}

}
